﻿using ConfExpert.Forms.Base;
using DevTeam;

using System;
namespace ConfExpert.Forms.SatinAlma
{
    public partial class MalsahibiDegistir : XForm
    {
        public MalsahibiDegistir()
        {
            InitializeComponent();
        }

        private void MalsahibiDegistir_Load(object sender, EventArgs e)
        {
            
            btnAdd.Click += btnAdd_Click;
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            gleOwnerId.Edit.Assign(RI(Rp.V_Customer));
            gleOwnerId.EditValue = 42;

            gridView1.Init("GetSepetOwner", WhoAmI, string.Empty);
            gridView1.FormatAsNumber(1, "Qty");
            gridView1.AddSummary("Qty");
            gridView1.BestFitColumns();

            btnKaydet.Enabled = false;
            teFaturaNo.EditValueChanged += teFaturaNo_EditValueChanged;
            gridView1.MakeReadOnly();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.EndEditing();
            string str = gridView1.Serialize();
            ExecuteNonQuery("UpdSepetOwner", str, gleOwnerId.EditValue.ToInt(), teFaturaNo.EditValue.ToStr(), WhoAmI);
            ShowInfoMessage("Güncelleme başarılı.");
        }

        void teFaturaNo_EditValueChanged(object sender, EventArgs e)
        {
            btnKaydet.Enabled = teFaturaNo.EditValue.ToStr().Length > 0;
        }

        void btnAdd_Click(object sender, EventArgs e)
        {
            gridView1.RefreshDataSource(true, "GetSepetOwner", WhoAmI, memoEdit1.Text);
            gridView1.BestFitColumns();
        }
    }
}
